﻿@model CMS.Common.Helpers.PagedData<CMSApplication.Models.OrderModels>
<script type="text/javascript">
    $(document).ready(function () {
        $(".page-number").click(function () {
            var page = parseInt($(this).html());
            $.get("/Order/List?&page=" + page, function (data) {
                $(".list").html("");
                $(".list").html(data);
            });
        });
        //             $(".list").html("");
        //        $(".list").html(data);
        $("a.delete").click(function () {

            var $this = $(this);
            var NameItem = $this.closest('tr').find('.spanName').html();
            if (confirm("Are you sure delete order : " + NameItem + "")) {
                var IdItem = $this.closest('tr').find('.Spanid').html();
                $.get("/Order/Delete?Id=" + IdItem, function () {
                    $.get("/Order/List?page=" + 1, function (data) {
                        $(".list").html("");
                        $(".list").html(data);
                    });
                });
            }
        });

    });

</script>
@if (Model.Data.Count() > 0)
{
    <table class="table dataTable" style="width: 100%">
        <thead>
            <th>
                Project Name
            </th>
            <th>
                Order By
            </th>
            <th style="width: 60px;">
                Order Date
            </th>
            <th>
                Address
            </th>
            <th style="width: 20px;">
                Size
            </th>
            <th>
                Type
            </th>
            <th style="width: 40px;">
                Status
            </th>
            <th width="10px">
                Action
            </th>
        </thead>
        <tbody>
            @foreach (var item in Model.Data)
            {
                <tr>
                    <td>
                        <span class="Spanid" style="display: none;">@item.Id</span> <span><a class="spanName" href="@Url.Action("Details", "Order", new { id = item.Id })">@item.Title</a>
                        </span>
                    </td>
                    <td>
                        <span>@item.OrderByName</span>
                    </td>
                    <td>
                        <span>@string.Format("{0:MM/dd/yyyy}", item.OrderDate) </span>
                    </td>
                    <td>
                        <span><a href="http://maps.google.com/maps?output=csv&oe=utf8&sensor=false&q=@item.Address" target="_blank">@item.Address</a></span>
                    </td>
                    <td>
                        <span>@item.Size </span>
                    </td>
                    <td>
                        <span>@item.Type </span>
                    </td>
                    <td>
                        <span>@item.Status </span>
                    </td>
                    <td>
                        <a href="@Url.Action("Edit", "Order", new { id = item.Id })" class="icon-pencil">
                        </a>@*<a href="javascript:void(0)" class="icon-trash delete"></a>*@
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <div class="dataTables_paginate paging_full_numbers" id="tSortable_2_paginate">
        <span>
            @for (int m = 1; m <= Model.NumberOfPages; m++)
            {
                if (m == Model.CurrentPage)
                {
                <a href="javascript:void(0);" tabindex="0" class="paginate_active page-number-Current page-number">@m</a>
                }
                else
                {
                <a class="paginate_button page-number" href="javascript:void(0);" tabindex="0">@m</a>
                }
            }
        </span>
    </div>
}
else
{
    <table class="table dataTable" style="width: 100%">
        <thead>
            <th>
                Title
            </th>
            <th>
                Order By
            </th>
            <th>
                Order Date
            </th>
            <th>
                Address
            </th>
            <th>
                Size
            </th>
            <th>
                Type
            </th>
            <th>
                Status
            </th>
            <th>
                Link
            </th>
            <th>
                Percent
            </th>
            <th width="10px">
                Action
            </th>
        </thead>
        <tbody>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
        </tbody>
    </table>
}
